import { defineStore } from 'pinia'
import { ref } from 'vue'

export const BlogStore = defineStore(
    'blog',
    () => {
        const data: { [key: string]: any } = ref({})
        const resetCache = () => {
            data.value = {}
        }
        const addCache = (key: string, value: any) => {
            data.value[key] = value
        }
        const removeCache = (key: string) => {
            data.value[key] = null
        }
        const getCache = (key: string) => {
            return data.value[key]
        }
        return { data, addCache, getCache, resetCache, removeCache }
    },
    {
        persist: {
            key: 'Blog',
            storage: localStorage
        }
    }
)
